//
//  SplashscreenViewController.m
//  Lextra Junior ueb IT
//
//  Created by Dirk Lieder on 26.05.11.
//  Copyright 2011 Phosphon. All rights reserved.
//

#import "SplashscreenViewController.h"

#import "Lextra_Engine.h"

@implementation SplashscreenViewController

@synthesize version;
@synthesize bildButton;


NSTimer *loadTimer;


- (void)setDelegate:(id)new_delegate{
	Delegate = new_delegate;
}

- (IBAction) cancel:(id)sender{
	[self stopTimer];	
	[Delegate goScreen:2 theName:@"" thePara:nil deliteView:TRUE];
}

- (void)timeoutTimer{
	[Delegate goScreen:2 theName:@"" thePara:nil deliteView:TRUE];
}

- (void)stopTimer
{
	[loadTimer invalidate];
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
	NSString *theVersion  = NSLocalizedString(@"version", @"");
	version.text = theVersion;
	
	// delay splash screen
	loadTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(timeoutTimer) userInfo:NULL repeats:NO];
    
    [super viewDidLoad];
	
	// after load show text
	bildButton.alpha = 0;
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.75];
	bildButton.alpha = 1;
	[UIView commitAnimations];
}

- (void)viewDidUnload
{
    [self stopTimer];

    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
//__NGUYEN_HUY_SON
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        return YES;
    }
    else
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
}
//___END_NGUYEN_HUY_SON___

@end
